home *** CD-ROM | disk | FTP | other *** search
Lisp/Scheme | 1994-06-25 | 1.1 KB | 40 lines | [TEXT/xlsp] |
- ; dragon.lsp for MacXLisp 2.1g by Tom Almy and Brian Kendig
- ;
- ; An Nth-order dragon curve using turtle drawing routines.
- ; Originally from Byte (April 1986), converted to xlisp
- ; by Peter Ashwood-Smith, modified by Tom Almy and Brian Kendig.
- ;
- ; Note that you have to have turtle.lsp loaded for this to work.
- ; And you might want to press Command-Period to stop the program
- ; when it starts drawing beyond the window where you can't see it.
- ;
- ; P.S - This dragon is nicknamed "spot".
-
- #-:turtle (load "turtle")
-
- (defvar *StepSize* 1)
-
- (defun Dragon (sign level)
- (if (zerop level)
- (TurtleForward *StepSize*)
- (progn
- (setq level (1- level))
- (TurtleRight (* 45 sign))
- (Dragon -1 level)
- (TurtleLeft (* 90 sign))
- (Dragon 1 level)
- (TurtleRight (* 45 sign)))))
-
- (defun DragonCurve (n m)
- (setq *StepSize* m) ; *StepSize* is global variable
- (TurtleGraphicsUp)
- (color 0 40000 0)
- (TurtleCenter)
- (TurtleGoto 50 50)
- (TurtleRight 30) ; angle the serpent a bit
- (Dragon 1 n)
- (gc))
-
- (print "Try (DragonCurve 14 3)")
-
-